package com.joysuch.wwyt.app.controller;

import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.risk.bean.RiskDistrictSumDto;
import com.joysuch.wwyt.risk.bean.RiskLevelListBean;
import com.joysuch.wwyt.risk.bean.RiskLevelListSearchBean;
import com.joysuch.wwyt.risk.service.RiskPointService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 风险分级管控
 *
 * @Author ZhangDong
 * @Date 2020/6/17 15:43
 */
@RestController
@RequestMapping("/bp/app/risk")
@Api(tags = "/bp/app/risk 风险分级管控")
@CrossOrigin
public class AppRiskDistrictController {

    @Autowired
    private RiskPointService riskPointService;

    @GetMapping("district-page")
    @ApiOperation(value = "分页查询", response = RiskLevelListBean.class)
    public ResultBean districtPage(Pageable page, RiskLevelListSearchBean searchBean) {
        Page<RiskLevelListBean> result = riskPointService.findRiskLevelControlPage(page, searchBean, 1);
        return ResultBean.pageData(result.getContent(), result.getTotalElements());
    }

    @GetMapping("risk-sum")
    @ApiOperation(value = "风险等级汇总", response = RiskDistrictSumDto.class)
    public ResultBean riskSum() {
        return riskPointService.riskSum();
    }
}
